<?php

/**
 * 
 * @author sunny5156  <137898350@qq.com>
 * @date 2015-8-26
 * @version
 */

namespace Common\Model;
class  RoleModel extends CommonModel{
    
    protected $pk   = 'role_id';
    protected $tableName =  'role';
    protected $token = 'role';

    //静态验证
    protected $_validate = array(
        array('role_name', 'require', '请填写角色名称！'),
    );


    /**
     * 添加/编辑
     * @author Kevin_ren  <330202207@qq.com>
     */
    public function saveData()
    {
        $data = I('post.', false);

        if ($this->create($data)) {

            if ($data['id']) {
                $result = $this->save($data);
            } else {
                $result = $this->add($data);
            }

            if ($result || $result !== false) {
                return true;
            } else {
                return false;
            }

        } else {
            return false;
        }
    }
}